﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CMN.BLL;
using CMN.Common;
using CMN.Entity;
using CMN.Models.Interfaces;
namespace CMN.Models
{
    /// <summary>
    /// 投票记录Service
    /// </summary>
    public class Normal_Vote_RecordService: IDataService<Normal_Vote_RecordEntity>
    {
        /// <summary>
        /// 新增投票记录
        /// </summary>
        /// <param name="Normal_Vote_RecordEntity"></param>
        /// <returns>bool</returns>
        public string Insert(Normal_Vote_RecordEntity normal_vote_recordEntity)
        {
            normal_vote_recordEntity.DataTable_Action = DataTableAction.Insert;
            Normal_Vote_Record bll = new Normal_Vote_Record();
            if (bll.InsertUpdateDelete(normal_vote_recordEntity) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 返回投票记录查询列表
        /// </summary>
        /// <param name="qp"></param>
        /// <param name="count">查询总个数</param>
        /// <returns>List</returns>
        public List<Normal_Vote_RecordEntity> List(QueryParam qp,out int count)
        {
            Normal_Vote_Record bll = new Normal_Vote_Record();
            return bll.List(qp, out count);
        }

        /// <summary>
        /// 更新投票记录
        /// </summary>
        /// <param name="Normal_Vote_Record"></param>
        /// <returns>bool</returns>
        public string Update(Normal_Vote_RecordEntity normal_vote_recordEntity)
        {
            normal_vote_recordEntity.DataTable_Action = DataTableAction.Update;
            Normal_Vote_Record bll = new Normal_Vote_Record();
            if (bll.InsertUpdateDelete(normal_vote_recordEntity) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 删除投票记录
        /// </summary>
        /// <param name="Normal_Vote_Record"></param>
        /// <returns>bool</returns>
        public string Delete(Normal_Vote_RecordEntity normal_vote_recordEntity)
        {
            normal_vote_recordEntity.DataTable_Action = DataTableAction.Delete;
            Normal_Vote_Record bll = new Normal_Vote_Record();
            if (bll.InsertUpdateDelete(normal_vote_recordEntity) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 批量删投票记录
        /// </summary>
        /// <param name="idList">删除id列表  2_8_9_45</param>
        /// <returns>bool</returns>
        public string DeleteList(string idList)
        {
            string[] list =Utils.SplitString(idList,"_");
            string strDel=Utils.ArrayToString(list,",",false);
            Normal_Vote_Record bll = new Normal_Vote_Record();
            if (bll.DelList(strDel) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }

        }

        /// <summary>
        /// 返回单个投票记录
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Normal_Vote_RecordEntity</returns>
        public Normal_Vote_RecordEntity Look(int id)
        {
            Normal_Vote_Record bll = new Normal_Vote_Record();
            return bll.Disp(id);
        }
    }
}
